﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace FileRenamer
{
    public partial class frmMain : Form
    {
        public frmMain()
        {
            InitializeComponent();
        }

        private void btnRenameFiles_Click(object sender, EventArgs e)
        {
            string[] files = System.IO.Directory.GetFiles(@"E:\My Documents\Mikes Music\", "*.*");

            foreach (var file in files)
            {
                var filename = System.IO.Path.GetFileName(file);
                var name = System.Text.RegularExpressions.Regex.Replace(filename,"[0-9]{2} - (.*)", "$1");
                try
                {
                    System.IO.File.Move(file, file.Replace(filename, name));
                }
                catch
                {
                    System.IO.File.Delete(file);
                }
            }
        }

  
    }
}
